const behavior = Behavior({
  properties: {
    openType: String,
    hoverStopPropagation: {
      type: Boolean,
      value: false,
    },
    hoverStartTime: {
      type: Number,
      value: 20,
    },
    hoverStayTime: {
      type: Number,
      value: 70,
    },
    lang: {
      type: String,
      value: 'zh_CN',
    },
    sessionForm: String,
    sendMessageTitle: String,
    sendMessagePath: String,
    sendMessageImg: String,
    appParameter: String,
    showMessageCard: Boolean,
  },

  methods: {
    _trigger(name, e) {
      const { detail } = e
      this.triggerEvent(name, detail)
    },

    onTap(e) {
      this._trigger('tap', e)
    },

    onGetUserInfo(e) {
      if (this.data.openType === 'getUserInfo') this._trigger('getuserinfo', e)
    },

    onContact(e) {
      if (this.data.openType === 'contact') this._trigger('contact', e)
    },

    onGetPhoneNumber(e) {
      if (this.data.openType === 'getPhoneNumber') this._trigger('getphonenumber', e)
    },

    onError(e) {
      this._trigger('error', e)
    },

    onOpenSetting(e) {
      if (this.data.openType === 'openSetting') this._trigger('opensetting', e)
    },

    onLaunchApp(e) {
      if (this.data.openType === 'launchApp') this._trigger('launchapp', e)
    },

    onChooseAvatar(e) {
      if (this.data.openType === 'chooseAvatar') this._trigger('chooseavatar', e)
    },
  },
})

module.exports = behavior
